package com.example.royalchef.fragment;

import com.example.royalchef.base.BaseFragment;

import java.util.HashMap;

/**
 * Created by Administrator on 2017/3/10.
 */

public class FragmentFactory {

    private static HashMap<Integer, BaseFragment> hashMap = new HashMap<>();

    public static BaseFragment createFragment(int position) {

        BaseFragment fragment = hashMap.get(position);
        if (fragment == null) {
            switch (position) {
                case 0:
                    fragment = new HomeFragment();
                    break;
                case 1:
                    fragment = new DynamicFragment();
                    break;
                case 2:
                    fragment = new PushFragment();
                    break;
                case 3:
                    fragment = new SettingFragment();
                    break;
                default:
                    break;
            }
        }
        hashMap.put(position, fragment);
        return fragment;
    }

}
